package com.lambda.use;

@FunctionalInterface
interface Callback {
    void onComplete(String result);
}

class Downloader {
    public void download(String url, Callback callback) {
        System.out.println("下载: " + url);
        // 模拟下载完成
        callback.onComplete("下载完成: " + url);
    }
}

public class CallbackExample {
    public static void main(String[] args) {
        Downloader downloader = new Downloader();

        // 使用Lambda表达式作为回调
        downloader.download("http://example.com",
                result -> System.out.println("回调结果: " + result));
    }
}